﻿using System;
using System.Collections.Generic;
using WpfApp1.Enum;

namespace WpfApp1.Model
{
    class Tools
    {

        // 时间戳格式化为日期文字
        public static string StampToDateTime(long stamp)
        {
            DateTime start = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            DateTime now = start.AddSeconds(stamp);

            return now.ToString("yyyy/MM/dd HH:mm:ss");
        }

        // 验证数据是否有效
        public static bool ValidData(object data)
        {
            return !(data == null || data.ToString().Length == 0);
        }

        // 获取枚举值
        public static List<ProductKind> GetProductKinds()
        {
            List<ProductKind> kinds = new List<ProductKind>();
            foreach(ProductKind kind in System.Enum.GetValues(typeof(ProductKind)))
            {
                Console.WriteLine("{0}",(int)kind);
                kinds.Add(kind);
            }

            return kinds;
        }
    }
}
